package com.qys.training.base.util;

import com.qys.training.base.enumerate.BizCodeEnum;
import com.qys.training.base.exception.QysException;
import org.apache.tomcat.jni.FileInfo;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

public class FileUtils {

    public static File uploadFile(MultipartFile file, String path) {
        try {
            File dest = new File(path).getCanonicalFile();
            if (!dest.getParentFile().exists()) {
                if (!dest.getParentFile().mkdirs()) {
                    System.out.println("was not successful.");
                }
            }
            file.transferTo(dest);
            return dest;
        } catch (Exception e) {
            throw new QysException(BizCodeEnum.UNKNOWN_ERROR.getCode(), null);
        }
    }


}
